﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace T2oop
{
    class student
    {
        private string name;

        public  string Name
        {
            get { return name; }
            set { name = value; }
                }

        private int age;
        
        //在属性中增加约束
        public int  Age
        {
            get { return age; }
            set {
                if (value <= 0 | value > 100)
                    throw new ArgumentException("年龄参数异常");
                    age = value; }
        }
        public override string ToString()
        {
              return string.Format("{0}:{1}", name, age);
         
        }
    }
}
